package com.factory.askQuestion.order;

import com.factory.askQuestion.piza.BasePiza;
import com.factory.simple_factory.SimpleFactory;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

//订购披萨的类
public class OrderPiza {

    //构造方法，用于预定披萨
    public OrderPiza() {
        BasePiza piza = null;
        do {
            String type = getPizaType();
            // **************** 工厂创建对象 ************
            piza = SimpleFactory.createPizza(type);
            //输出制作过程
            piza.prepare();
            piza.bake();
            piza.cut();
            piza.box();
        } while (true);
    }

    //得到用户想要订购那种披萨
    public String getPizaType() {
        try {
            BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("please input pizza type:");
            String type = bf.readLine();
            return type;
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }
}
